{% extends "base/base.html" %}

{% comment %}

 Copyright 2013 - Tom Alessi

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and 
 limitations under the License.

{% endcomment %}

{% block content %}

{% if queue %}

<div class="row">
  <div class="large-12 large-centered columns">
    <table>
      <tr>
    	 <th colspan="4" style="background:green;">ACTIVE SCANS</th>
      </tr>
      <tr>
        <th>Name</th>
        <th>Site</th>
        <th>Start Time</th>
        <th>Scan ID</th>
      </tr>

    {% for row in queue %}
      <tr>
      	<td>{{row.name__name}}</td>
      	<td>{{row.name__site__site}}</td>
      	<td>{{row.start}}</td>
        <td>{{row.report_uid}}</td>
      </tr>
    {% endfor %}

    </table>
    <br><br>
    {% else %}
    NO ACTIVE SCANS RUNNING
    <br><br>
    {% endif %}

  </div>
</div>


<script type="text/javascript">
$(function () {
        
        // Vulnerability Chart
        $('#vuls').highcharts({
            chart: {
                type: 'line',
                marginRight: 130,
                marginBottom: 65
            },
            title: {
                text: 'Scan Findings',
                x: -20 //center
            },
            subtitle: {
                text: 'Last 30 days, across all sites',
                x: -20
            },
            xAxis: {
                categories: [{% for row in severity_info %}{% if forloop.last %}'{{row.start|date:"Y-m-d"}}'{% else %}'{{row.start|date:"Y-m-d"}}',{% endif %}{% endfor %}],
                labels: {
                    rotation: -45,
                }
            },
            yAxis: {
                title: {
                    text: 'Vulnerabilities Detected'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: ' findings'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -10,
                y: 100,
                borderWidth: 0
            },
            series: [{
                name: 'Information',
                data: [{% for row in severity_info %}{% if forloop.last %}{{row.severity__information__sum}}{% else %}{{row.severity__information__sum}},{% endif %}{% endfor %}]
            }, {
                name: 'Low',
                data: [{% for row in severity_info %}{% if forloop.last %}{{row.severity__low__sum}}{% else %}{{row.severity__low__sum}},{% endif %}{% endfor %}]
            }, {
                name: 'Medium',
                data: [{% for row in severity_info %}{% if forloop.last %}{{row.severity__medium__sum}}{% else %}{{row.severity__medium__sum}},{% endif %}{% endfor %}]
            }, {
                name: 'High',
                data: [{% for row in severity_info %}{% if forloop.last %}{{row.severity__high__sum}}{% else %}{{row.severity__high__sum}},{% endif %}{% endfor %}]
            }]
        });



        //Requests Chart
        // Vulnerability Chart
        $('#reqs').highcharts({
            chart: {
                type: 'line',
                marginRight: 130,
                marginBottom: 65
            },
            title: {
                text: 'Requests Made',
                x: -20 //center
            },
            subtitle: {
                text: 'Last 30 days, across all sites',
                x: -20
            },
            xAxis: {
                categories: [{% for row in request_info %}{% if forloop.last %}'{{row.start|date:"Y-m-d"}}'{% else %}'{{row.start|date:"Y-m-d"}}',{% endif %}{% endfor %}],
                labels: {
                    rotation: -45,
                }
            },
            yAxis: {
                title: {
                    text: 'Occurrences'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -10,
                y: 100,
                borderWidth: 0
            },
            series: [{
                name: 'Urls',
                data: [{% for row in request_info %}{% if forloop.last %}{{row.urls_scanned__urls__sum}}{% else %}{{row.urls_scanned__urls__sum}},{% endif %}{% endfor %}]
            }, {
                name: 'Requests',
                data: [{% for row in request_info %}{% if forloop.last %}{{row.requests_made__requests__sum}}{% else %}{{row.requests_made__requests__sum}},{% endif %}{% endfor %}]
            }]
        });


    });

</script>
<script type="text/javascript" src="/html/js/highcharts.js"></script>


<div class="row">
  <div class="large-6 columns">
    <div id="vuls" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
    <br><br>
  </div>
    
  <div class="large-6 columns">
    <div id="reqs" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
  </div>
</div>







{% endblock %}
